<?php

namespace App\Http\Controllers\Backend\Api\V1;

use App\Http\Requests\Backend\BannerRequest;
use App\Services\Gallery\Interfaces\BannerServiceInterface;
use App\Services\Gallery\Model\Banner;
use App\Services\Gallery\Services\BannerService;
use Illuminate\Http\Request;

class BannerController extends BaseController
{
    /**
     * @var BannerService
     */
    protected $bannerService;

    public function __construct(BannerServiceInterface $bannerService)
    {
        $this->bannerService = $bannerService;
    }

    public function index(Request $request)
    {
        $banners = $this->bannerService->index($request->all());
        return $this->successData($banners);
    }

    public function create()
    {
        return $this->successData();
    }

    public function store(BannerRequest $request)
    {
        $this->bannerService->set($request->filldata());
        return $this->success();
    }

    public function edit($id)
    {
        $banner = $this->bannerService->get($id);
        return $this->successData(compact('banner'));
    }

    public function update(BannerRequest $request, $id)
    {
        $this->bannerService->set($request->filldata(), $id);
        return $this->success();
    }

    public function destroy($id)
    {
        $this->bannerService->destroy($id);
        return $this->success();
    }
}
